#! /bin/bash
echo "#================================================"
echo "Starting Build"
echo "Timestamp"
date -u
echo "#================================================"
echo

./stamp-pipofig-gen

VER=$(svn info | awk '/^Revision:/{print $2}')
let "VER+=1"

cd src

echo
echo "#================================================"
echo "Generate Translation Files"
echo "#================================================"
echo
./gen_ts

cd ..

echo
echo "#================================================"
echo "Build Windows Version"
echo "#================================================"
echo
cd winbuild
qmake ../src/pipofig.pro -spec win32-g++-cross
make
mv -v release/pipofig.exe .

#must copy win32-g++-cross directory to Qt mkspec directory (/usr/share/qt4/mkspecs)


echo
echo "#================================================"
echo "Package Windows Version"
echo "#================================================"
echo
makensis pipofig.nsi
mv -v pipofigInstall.exe ../

#must copy .nsh file to correct position
cd ..

echo
echo "#================================================"
echo "Build Linux i386 Version"
echo "#================================================"
echo
cd linux32build
qmake ../src/pipofig.pro -spec linux-g++-32 -r
make

#If build doesn't work you might need to link libraries in to /usr/bin/i386-linux-gnu/
#You might also need to force libraries -->
#in: /usr/share/qt4/mkspecs/linux-g++-32/qmake.conf
#to: QMAKE_LIBDIR_QT = /usr/lib/i386-linux-gnu/

echo
echo "#================================================"
echo "Package Linux i386 Version"
echo "#================================================"
echo
cp -v pipofig ../src/
#install copies pipofig from src folder.
cp -vf ../description-pak .
sudo checkinstall -D --nodoc -y --pkgname=pipofig --arch=i386 --pkgrelease=1 --pkgversion=$VER --maintainer=erazz --backup=no --install=no --requires="libqt4-gui ,libqt4-network ,libqt4-core ,libqt4-xml ,avrdude"
mv -vf "pipofig_"$VER"-1_i386.deb" ../pipofig-i386.deb


cd ..

echo
echo "#================================================"
echo "Build Linux amd64 Version"
echo "#================================================"
echo
cd linux64build
qmake ../src/pipofig.pro -spec linux-g++-64 -r
make

echo
echo "#================================================"
echo "Package Linux amd64 Version"
echo "#================================================"
echo
cp -v pipofig ../src/
#install copies pipofig from src folder.
cp -vf ../description-pak .
sudo checkinstall -D --nodoc -y --pkgname=pipofig --arch=amd64 --pkgrelease=1 --pkgversion=$VER --maintainer=erazz --backup=no --install=no --requires="libqt4-gui ,libqt4-network ,libqt4-core ,libqt4-xml ,avrdude"
mv -vf "pipofig_"$VER"-1_amd64.deb" ../pipofig-amd64.deb


cd ..



